/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "Hogshead.Core.h"
#include "../Directors/XInputDirector.h"
#include "../Hogshead.Input.Enums.h"


namespace Hogshead
{
	namespace Input
	{
		class XBoxControllerStateChangedMessage : public IMessage
		{
			MessageH(Hogshead::Input::XBoxControllerStateChangedMessage);
		public:
			XBoxControllerStateChangedMessage();
			ButtonState getButtonState(XBoxButton in_button) const;
			XBoxController getControllerID() const;
			float getTriggerValue(XBoxTrigger in_trigger) const;
			float getTriggerDelta(XBoxTrigger in_trigger) const;
			float getJoystickValue(XBoxJoystick in_stick) const;
			float getJoystickDelta(XBoxJoystick in_stick) const;

		private:
			void setData(XBoxController in_id, unsigned int in_states, unsigned int in_previous_button_states, const unsigned char* in_trigger_states, const unsigned char* _previous_trigger_states, 
				const short* in_thumbstick_states, const short* in_previous_thumbstick_states);
			XBoxController _controller_id;
			int _button_states;
			int _previous_button_states;
			unsigned char _trigger_states[2];
			unsigned char _previous_trigger_states[2];
			short _thumbstick_states[4];
			short _previous_thumbstick_states[4];
			friend class XInputDirector;

			static const int _enum_lookup_table[14];

		};
	}
}